Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: speed up transformation of debug messages #3814

Closed
wants to merge 5 commits into from

Conversation

TomAFrench
Copy link
Member

Description

Problem*

Resolves #3809

Summary*

This PR modifies the algorithm for how we map the debug information when we optimize/transform the circuit such that it scales linearly with the number of opcodes rather than quadratically.

Previously we would:

  • Take an old opcode location
    • Search the entire new circuit for opcodes which were mapped from that opcode
    • Apply the debug information to each new opcode.
  • repeat until no more opcode locations exist.

This then has to search through the entire list of opcodes once per opcode. We know that optimisation/transformation doesn't reorder opcodes so a lot of this work is unnecessary, we can instead build up a reverse mapping in a single pass and then just use that.

I've changed the debug info transformation process to build a mapping from an old opcode location to the set of corresponding new opcode locations once, we can then just iterate through all of the opcode locations and map them to the new opcode locations.

There's still some issues in this code. We were (and still are) treating all opcodes with the same ACIR index as coming from the same location. This likely means we're either: a) not mapping brillig opcodes correctly or b) unnecessarily mapping brillig opcodes multiple times. I'm not too bothered about this for this PR as the behaviour is unchanged and it's more important to get the speed increase on master rather than chase potential improvements.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [Exceptional Case] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@TomAFrench
Copy link
Member Author

Superceded by #3815

@TomAFrench TomAFrench closed this Dec 15, 2023
github-merge-queue bot pushed a commit that referenced this pull request Dec 15, 2023
# Description
Same as #3814 but with a different
approach, by building the map of old to new inside AcirTransformationMap
## Problem\*

Resolves #3809

## Summary\*



## Additional Context



## Documentation\*

Check one:
- [ ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [ ] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
github-merge-queue bot pushed a commit that referenced this pull request Dec 15, 2023
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

This pulls across the housekeeping changes from #3814 which weren't
included in #3815

## Additional Context


## Documentation\*

Check one:
- x ] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@TomAFrench TomAFrench deleted the tf/faster-debug-transformations branch January 14, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating debug information after optimizing a circuit is way too slow.
1 participant